package org.sws.domain.strategy.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author sws
 * @Date 2025/2/17 22:37
 * @description:
 */
@Getter
@AllArgsConstructor
public enum LogicModel {
    RULE_BLACKLIST("rule_blacklist","【抽奖前规则】黑名单规则过滤，命中黑名单则直接返回","before"),
    RULE_WIGHT("rule_weight","【抽奖前规则】根据抽奖权重返回可抽奖范围KEY","before"),
    RULE_DEFAULT("rule_default","默认抽奖","before"),

    RULE_LOCK("rule_lock", "【抽奖中规则】抽奖n次后，对应奖品可解锁抽奖","center"),

    RULE_RANDOM("rule_random", "【抽奖中规则】随机积分奖励", "after"),
    RULE_LUCK_AWARD("rule_luck_award", "【抽奖后规则】兜底幸运奖品", "after")

    ;


    private final String code;
    private final String info;
    private final String type;

    public static String getInfo(String ruleModel) {
        for (LogicModel logicModel : LogicModel.values()) {
            if (logicModel.code.equals(ruleModel)) {
                return logicModel.info;
            }
        }
        return null;
    }
    public static List<String> getBeforeLogic(){
       return Arrays.stream(LogicModel.values())
               .filter(it -> it.type.contains("before"))
               .map(LogicModel::getCode)
               .collect(Collectors.toList());
    }
}
